/**
 * 混合玩法楼层中 加入房间时 弹出的玩法信息界面
 */
var ClubJoinRoomTipsWindow = Window.extend({
    _ccsFileName: res.ClubJoinRoomTipsWindow_json,
    _callBack: null,
    initWindow: function (wanfaInfo, callBack) {
        this._callBack = callBack;
        var roomInfo = wanfaInfo.roomInfo;
        for (var i = 0; i < 4; i++) {
            this._nodeList['player' + i].setVisible(false);
            if (roomInfo && roomInfo.heads[i] && roomInfo.nicknames[i] && roomInfo.uids[i]) {
                this._nodeList['player' + i].setVisible(true);
                loadImageToSprite(roomInfo.heads[i], this._nodeList['player' + i + '.head']);
                // this._nodeList['player' + i + '.nickname'].setString(roomInfo.nicknames[i]);
                this._nodeList['player' + i + '.nickname'].setString(ellipsisStr(roomInfo.nicknames[i], ClubDataManager.NirckNameSize));
                this._nodeList['player' + i + '.ip'].setString('ID:' + roomInfo.uids[i]);
            }
        }
        if (wanfaInfo.roomInfo && wanfaInfo.roomInfo.option) {
            var option = JSON.parse(wanfaInfo.roomInfo.option);
            this._nodeList['wanfa_content'].setString(this._handleWanfaDesp(option.desp));
        } else if (wanfaInfo.desc) {
            this._nodeList['wanfa_content'].setString(this._handleWanfaDesp(wanfaInfo.desc));
        }
    },

    _initClickListeners: function () {
        this._clickListeners = {
            'btn_sure_enter': '_clickSuer',
        }
    },
    _clickSuer: function () {
        if (this._callBack) {
            this._callBack()
        }
        this.close();
    },
    _handleWanfaDesp: function (wanfaDesp){
        var removedStrArr =['王钓麻将', '落地扫', '永州扯胡子', '2人PK', '3人激情', '2人玩', '3人玩', '4人玩',
            '局数: 6局', '局数: 8局', '局数: 10局', '群主支付', '房主支付', 'AA支付'];
        var retVal = wanfaDesp;
        var retValArr = retVal.split(',');
        var locationArr = [];
        for (var i = 0; i < retValArr.length; i++){
            retValArr[i] = retValArr[i].trim();
            if (removedStrArr.indexOf(retValArr[i]) > -1) locationArr.push(i);
        }

        for (var i = locationArr.length - 1; i > -1; i--){
            retValArr.splice(locationArr[i], 1);
        }

        retVal = retValArr.join(',');

        return retVal;
    },

});